package com.gpslw.mvc.config;

import com.gpslw.mvc.event.UserSaveEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserService {

    @Autowired
    private ApplicationContext applicationContext;

    public UserService() {
        System.out.println("this is test");
    }

    @Transactional
    public void saveUser(){
        System.out.println("======");
        applicationContext.publishEvent(new UserSaveEvent(this));
        System.out.println("after publish");
    }


}
